function [aggSaving, g] = solveKF(r, A, incomeStruct, prefStruct, Xstruct, simStruct);
%{
%%-------------------------------------------------------------------------
Finds the stationary distribution using the Kolmogorov Forward Equation
%%-------------------------------------------------------------------------
%}

%%-------------------------------------------------------------------------
%Unpack Structs / Setup
    I = Xstruct.I;
    xjump = Xstruct.xjump;
	X_ = Xstruct.X_;
%%-------------------------------------------------------------------------
	
%%-------------------------------------------------------------------------
% Find Stationary Distribution
    AT = A';
    b = zeros(2*I,1);

    %need to fix one value, otherwise matrix is singular
    i_fix = 1;
    b(i_fix)=.1;
    row = [zeros(1,i_fix-1),1,zeros(1,2*I-i_fix)];
    AT(i_fix,:) = row;

    %Solve linear system
    gg = AT\b;
    
    %Normalize
    g_sum = gg'*ones(2*I,1)*xjump;
    gg = gg./g_sum;

    g = [gg(1:I), gg(I+1:2*I)];
    
    aggSaving = g(:,1)'*X_*xjump + g(:,2)'*X_*xjump;
%%-------------------------------------------------------------------------
